import time
import image2
from ILI9431c import ILI9341
from machine import Pin, SPI


#画笔颜色
WHITE = 0xFFFF #白色
BLACK = 0x0000 #黑色
BLUE  = 0x001F #蓝色
BRED  = 0XF81F
GRED  = 0XFFE0
GBLUE = 0X07FF
RED   = 0xF800 #红色
MAGENTA = 0xF81F #紫红色
GREEN   = 0x07E0 #绿色
CYAN    = 0x7FFF #青色
YELLOW  = 0xFFE0 #黄色
BROWN   = 0XBC40 #棕色
BRRED   = 0XFC07 #棕红色
GRAY    = 0X8430 #灰色

#GUI颜色
DARKBLUE  = 0X01CF #深蓝色
LIGHTBLUE = 0X7D7C #浅蓝色
GRAYBLUE  = 0X5458 #灰蓝色
#以上三色为PANEL的颜色 

LIGHTGREEN  = 0X841F #浅绿色
LIGHTGRAY   = 0XEF5B #浅灰色(PANNEL)
LGRAY       = 0XC618 #浅灰色(PANNEL),窗体背景色

LGRAYBLUE   = 0XA651 #浅灰蓝色(中间层颜色)
LBBLUE      = 0X2B12 #浅棕蓝色(选择条目的反色)


LCD_WIDTH = 240
LCD_HEIGHT = 320

# esp32管脚
# spi = SoftSPI(
#     baudrate=40000000,
#     miso=Pin(19),
#     mosi=Pin(23),
#     sck=Pin(18))
# 
# display = ILI9341(
#     spi,
#     cs=Pin(5),
#     dc=Pin(26),
#     rst=Pin(27),
#     bl=Pin(14),
#     w=240,
#     h=320,
#     r=0)

#esp32s3管脚
spi = SPI(
    baudrate=8000000,
    mosi = Pin(11),
    miso = Pin(13),
    sck=Pin(12)
    )

display = ILI9341(
    spi,
    cs=Pin(8),
    dc=Pin(6),
    rst=Pin(5),
    bl=Pin(7),
    w=240,
    h=320,
    r=0)

image = image2.Imagedata2

# 使用数组显示,适合图像小于240*160
# display.arrmap(0, 0, LCD_WIDTH, LCD_HEIGHT, image)
# 使用字典显示。适合图像大于240*180
display.dicmap(0, 0, LCD_WIDTH, LCD_HEIGHT, image)

# for v in range(len(image)):
#     print(image[v])










